<template>
  <div>
    <a-card :bordered='false'>
      <f-search-form :more='true' @searchHandler='searchHandler' :tableObj='tableObj' :show-export-btn='true' :exportUrl='api.erpSearch.exportProcureDetailList'>
        <f-search-form-item label='单据日期' type='range' name='beginDate' />
        <f-search-form-item label='单位名称' name='customNo' type='select' :data='api.erpSearch.selectHyCustomList' :params='queryParam' value-key='customNo' label-key='customName' :show-all='false' :show-search='true' />
        <f-search-form-item label='商品名称' name='drugNo' type='select' :data='api.erpSearch.selectDrugList' :params='queryParam' value-key='drugNo' :show-search='true' label-key='drugsName' />
        <f-search-form-item slot='advanced' label='部门名称' name='deptNo' type='select' :data='api.erpSearch.selectHyDeptList' :params='queryParam' value-key='deptNo' label-key='deptName' />
        <f-search-form-item slot='advanced' label='批号' name='lotNo' />
        <f-search-form-item slot='advanced' label='单据编码' name='procureNo' />
        <f-search-form-item slot='advanced' label='业务员' name='saleManBusinessNo' />
        <f-search-form-item slot='advanced' label='制单人' name='userName' />
      </f-search-form>
      <f-table ref='table' settingKey='procureDetailsList' rowKey='procureNo' :showSetting='true' :tableColumns='columns' :scroll='{x:true}' :multiple='false' :operator='operator' :params='queryParam' :api='api.erpSearch.procureDetailList' handler='exportListHandler'>
         <span slot='procureType' slot-scope='text, record'>
          <template>
              <a-tag v-if='text=="CKA"'>销售出库</a-tag>
              <a-tag v-if='text=="CKJ"'>销售退回</a-tag>
              <a-tag v-if='text=="CKI"'>退补差价</a-tag>
              <a-tag v-if='text=="CKB"'>调拨出库</a-tag>
              <a-tag v-if='text=="CKG"'>其他出库</a-tag>
              <a-tag v-if='text=="CKF"'>移出出库</a-tag>
              <a-tag v-if='text=="CKL"'>领用出库</a-tag>
              <a-tag v-if='text=="CKE"'>赠品出库</a-tag>
              <a-tag v-if='text=="CKC"'>报损出库</a-tag>
              <a-tag v-if='text=="CKD"'>盘亏出库</a-tag>
    
              <a-tag v-if='text=="RKB"'>采购验收</a-tag>
              <a-tag v-if='text=="RKN"'>进货退出</a-tag>
              <a-tag v-if='text=="RKM"'>退补差价</a-tag>
              <a-tag v-if='text=="RKF"'>商品损溢</a-tag>
              <a-tag v-if='text=="RKI"'>报升入库</a-tag>
              <a-tag v-if='text=="RKD"'>盘盈入库</a-tag>
              <a-tag v-if='text=="RKA"'>期初入库</a-tag>
          </template>
      </span>
        <span slot='ywfl' slot-scope='text, record, index'>
          <a-tag color='#FF0000' v-if='text=="ZS"'>
          招商
        </a-tag>
        <a-tag color='#00FF00' v-if='text=="ZY"'>
          自营
        </a-tag>
      </span>
      </f-table>
    </a-card>

  </div>
</template>
<script>
import api from "./../../js/api"

export default {
  name: "MingXiList",
  components: {},
  data() {
    let me = this
    //操作按钮
    let operator = []
    let customFlag = this.$store.state.user.customFlag
    return {
      api: Object.assign(api, this.api),
      //列表初始化查询参数
      queryParam: {
        companyId: this.$store.state.user.companyId
      },
      tableObj: null,
      superAdmin: this.superAdmin,
      // 表头
      columns: [
        {
          title: "序号",
          width: "70px",
          align: "center",
          fixed: "left",
          customRender: (text, record, index) => index + 1
        },
        {
          title: "单据日期",
          align: "left",
          width: "100px",
          fixed: "left",
          dataIndex: "procureDate"
        },
        {
          title: "部门名称",
          align: "left",
          fixed: "left",
          ellipsis: true,
          width: "100px",
          dataIndex: "deptName"
        },
        {
          title: "单据编码",
          align: "left",
          fixed: "left",
          width: "115px",
          dataIndex: "procureNo"
        },
        {
          title: "商品名称",
          fixed: "left",
          align: "left",
          ellipsis: true,
          dataIndex: "spmc"
        },
        {
          title: "方式名称",
          align: "left",
          width: "80px",
          dataIndex: "procureType",
          scopedSlots: { customRender: "procureType" }
        },
        {
          title: "通用名",
          align: "left",
          width: "75px",
          ellipsis: true,
          dataIndex: "tym"
        },
        {
          title: "规格",
          align: "left",
          width: "80px",
          ellipsis: true,
          dataIndex: "gg"
        },
        {
          title: "批号",
          align: "left",
          width: "70px",
          dataIndex: "ph"
        },

        {
          title: "单位名称",
          align: "left",
          width: "80px",
          ellipsis: true,
          dataIndex: "customName"
        },
        {
          title: "业务员",
          align: "left",
          width: "90px",
          dataIndex: "saleManName"
        },
        {
          title: "制单人",
          align: "left",
          width: "100px",
          dataIndex: "userName"
        },
        {
          title: "生产企业",
          align: "left",
          width: "120px",
          ellipsis: true,
          dataIndex: "scqy"
        },
        {
          title: "上市许可持有人",
          align: "left",
          width: "120px",
          ellipsis: true,
          dataIndex: "cyr"
        },
        {
          title: "件容",
          align: "left",
          width: "70px",
          dataIndex: "jr"
        },
        {
          title: "单位",
          align: "left",
          width: "70px",
          dataIndex: "dw"
        },
        {
          title: "有效期至",
          align: "left",
          width: "70px",
          dataIndex: "yxqz"
        },
        {
          title: "生产日期",
          align: "left",
          width: "70px",
          dataIndex: "scrq"
        },
        {
          title: "销售单价",
          align: "left",
          width: "70px",
          dataIndex: "hsdj"
        },
        {
          title: "数量",
          align: "left",
          width: "70px",
          dataIndex: "sl"
        },
        {
          title: "销售金额",
          align: "left",
          width: "70px",
          dataIndex: "hsje"
        },
        {
          title: "无税单价",
          align: "left",
          width: "100px",
          dataIndex: "wsdj"
        },
        {
          title: "无税金额",
          align: "left",
          width: "100px",
          dataIndex: "wsje"
        },
        {
          title: "件数",
          align: "left",
          width: "70px",
          dataIndex: "js"
        },
        {
          title: "效期",
          align: "left",
          width: "80px",
          dataIndex: "xq"
        },
        {
          title: "业务分类",
          align: "left",
          width: "80px",
          dataIndex: "ywfl",
          scopedSlots: { customRender: "ywfl" }
        }, {
          title: "备注",
          align: "left",
          width: "100px",
          dataIndex: "bz"
        }
      ],
      operator: operator
    }
  },
  created() {
  },
  mounted() {
    this.tableObj = this.$refs.table
  },
  methods: {
    onCopy() {
      this.$message.success("复制成功!")
    },
    exportData() {
      this.http.exportExcel(this, {
        url: this.api.erpSearch.exportProcureDetailList,
        data: {
          handlerName: "exportListHandler",
          columns: "[{name:'单号',key:'paymentNo'},{name:'供货商',key:'supplierName'},{name:'应返金额',key:'supplierRetable',isStatistics:true},{name:'开票金额',key:'invoiceAmount',isStatistics:true},{name:'税金金额',key:'amount',isStatistics:true},{name:'开票单位',key:'invoiceunitName'},{name:'收款账户',key:'bankName'},{name:'开票日期',key:'amountDate'},{name:'支付日期',key:'payDate'},{name:'申请人',key:'nickName'}]"
        }
      })
    },
    initSettle(record) {
      // this.http.confirm(this, {
      //   content: '确认初始化结算吗?',
      //   url: api.payment.initSettlePayment,
      //   data: {
      //     orderDetailsId: record.orderDetailsId
      //   }
      // })
    },
    clearExport() {
      this.http.post(this, {
        url: this.api.bod.clearExportData
      })
    }
  }
}
</script>
<style scoped lang='less'>

</style>